﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BotonJXC.Entity;
using BotonJXC.DAO;
using NHibernate;

namespace BotonJXC.BLL
{
    public class AllocatesBLL : BaseBLL<AllocatesDAO, Allocates, int>
    {
        public AllocatesBLL()
        { 
        }

        /// <summary>
        /// 条件查询调拨单
        /// </summary>
        /// <param name="allocate"></param>
        /// <param name="start"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public PageModel<Allocates> findAllocatesByCondition(Allocates allocate, int start, int count)
        {
            return base.Dao.findAllocatesByCondition(allocate, start, count);
        }

        /// <summary>
        /// 根据ID查询调拨单
        /// </summary>
        /// <param name="allocateid"></param>
        /// <returns></returns>
        public Allocates findAllocatesById(string allocateid)
        {
            return base.Get(Int32.Parse(allocateid));
        }

        public void DeleteAllocateProduct(AllocatesProducts pro)
        {
            HBHelper.Session.Delete(pro);
        }

        /// <summary>
        /// 根据调拨单编号查询订单
        /// </summary>
        /// <param name="orderSn"></param>
        /// <returns></returns>
        public Allocates findAllocatesBySn(string AllocateSn,string AllocateType)
        {

            IList<Allocates> list = base.Dao.findAllocatesBySn(AllocateSn , AllocateType);
            if (list != null && list.Count > 0)
            {
                return list[0];
            }
            else
            {
                return null;
            }
        }
    }
}
